import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/getParameter")
public class GetParameterServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 获取GET请求中的query string 的内容
        // 请求形如 /message?aa=10&bb=20
        // 上述 query string, 就会被 tomcat 给自动解析成一个 Map 这样的结构.
        // getParameter 就是在查询 Map<String, String> 里的内容
        String aa = req.getParameter("aa");
        String bb = req.getParameter("bb");

        System.out.println("aa:" + aa);
        System.out.println("bb:" + bb);

        // 返回响应
        resp.getWriter().write("ok");
    }
}
